# -*- coding: utf-8 -*-
# @Time : 2022/4/9 23:33
# @Author : Liuqing
# @File : 32_列表元素频次统计.py
# @Software : PyCharm
lst = [1, 2, 3, 4, 5, 6, 7, 8, 3, 3, 4, 5, 2, 3, 2]

# 方法一，for循环
frequ_dict = {}
for i in lst:
    # 在字典中，相应的值+1
    if i in frequ_dict.keys():
        frequ_dict[i] += 1
    else:
        frequ_dict[i] = 1
print(frequ_dict)

# 方法二。Counter类
from collections import Counter

counter = Counter(lst)
print(counter.most_common())
